{* $Id: file_uploader.html 22514 2013-04-08 07:49:45Z weisd $ *}
{*swfupload插件*}
{load_js file="swfupload/swfupload.js"}
{load_js file="swfupload/swfupload.queue.js"}
{load_js file="swfupload/swfupload.speed.js"}
{load_js file="swfupload/swfupload.fileprogress.js"}
{load_js file="swfupload/handlers.js"}
<h2 class="wuQS">上传列队</h2><!-- 上传总进度条 -->
请使用上传按钮选择一个或多个文件
<div class="wuQDesc">图片支持jpg、png、gif、jpeg格式，视频支持flv格式；拖动队列中的文件可以进行排序。</div>
<div id="wuQError" style="color:red;"></div>
<div class="wuQ" id="uploaderQueue">
  <table></table>
</div><!-- 上传列队 -->
<br />
<div id="uploaderOverlay" style="display: inline; position: absolute; z-index: 2;">
</div><!-- 上传按钮 -->
<div id="btnContainer">
    <button type="button" id="btnBrowse"><span>Add files</span></button> &nbsp;
    <button type="button" id="btnClear"><span></span></button>
</div><!-- 上传控制按钮 -->
<script type="text/javascript">
var swfu;
var resName = "{$res_name}";
var viewOrder = 0;
var defaultData;
$(function(){
	// 获取默认的附件
	defaultData = {$res_name|get_res_attachments:$res_id|@json_encode}; // For edit
	jQuery.each(defaultData, function(k, v){
		queueData(v, true);
	});
	var settings = {
		flash_url : "{$smarty.const.SITE_URL}/js/swfupload/swfupload.swf",
		upload_url: "{$smarty.const.SITE_URL}/core/handler/file_uploader",
		button_image_url: "{$smarty.const.SITE_URL}/images/admin/buttonSkin.png",
    {literal}
		post_params: {"res_name":resName},
		file_size_limit : "2 MB",
		file_types : "*.jpg;*.gif;*.png;*.jpeg;*.bmp;*.flv;",
		file_types_description : "All Files",
		file_upload_limit : 100,
		file_queue_limit : 0,
		custom_settings : {
			cancelButtonId : "btnClear"
		},
		debug: false,

		// Button settings
		button_width: "120",
		button_height: "30",
		button_placeholder_id: "btnBrowse",
		button_cursor : SWFUpload.CURSOR.HAND,

		// The event handler functions are defined in handlers.js
		//当Flash控件成功加载后触发的事件处理函数
	    swfupload_loaded_handler : AnSWFUHandlers.swfUploadLoaded,
	    //当文件选取对话框弹出前出发的事件处理函数
	    file_dialog_start_handler : AnSWFUHandlers.fileDialogStart,
		file_queued_handler : AnSWFUHandlers.fileQueued,
		file_queue_error_handler : AnSWFUHandlers.fileQueueError,
		file_dialog_complete_handler : AnSWFUHandlers.fileDialogComplete,
		upload_start_handler : AnSWFUHandlers.uploadStart,
		upload_progress_handler : AnSWFUHandlers.uploadProgress,
		upload_error_handler : AnSWFUHandlers.uploadError,
		upload_success_handler : AnSWFUHandlers.uploadSuccess,
		upload_complete_handler : AnSWFUHandlers.uploadComplete,
		// Queue plugin event
		queue_complete_handler : AnSWFUHandlers.queueComplete
	};

	var swfu = new SWFUpload(settings);
    //拖动排序
    $("#uploaderQueue table").sortable({
      cursor : 'move',
      placeholder : 'ui-state-highlight',
      stop : function(event, ui){
               $(".viewOrder", $("#uploaderQueue")).each(function(k, v){
                   $(this).val(k+1);
                   $(this).prev(".oldViewOrder").val(k+1);
               });
             }
    });
});
{/literal}
</script>